home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / php / Zend / zend_list.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  4.1 KB  |  110 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | Zend Engine                                                          |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 0.92 of the Zend license,     |
  8.    | that is bundled with this package in the file LICENSE, and is        | 
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.zend.com/license/0_92.txt.                                |
  11.    | If you did not receive a copy of the Zend license and are unable to  |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@zend.com so we can mail you a copy immediately.              |
  14.    +----------------------------------------------------------------------+
  15.    | Authors: Andi Gutmans <andi@zend.com>                                |
  16.    |          Zeev Suraski <zeev@zend.com>                                |
  17.    +----------------------------------------------------------------------+
  18. */
  19.  
  20.  
  21. #ifndef ZEND_LIST_H
  22. #define ZEND_LIST_H
  23.  
  24. #include "zend_hash.h"
  25. #include "zend_globals.h"
  26.  
  27.  
  28. #define ZEND_RESOURCE_LIST_TYPE_STD    1
  29. #define ZEND_RESOURCE_LIST_TYPE_EX    2
  30.  
  31. typedef struct _zend_rsrc_list_entry {
  32.     void *ptr;
  33.     int type;
  34.     int refcount;
  35.     zend_bool valid;
  36. } zend_rsrc_list_entry;
  37.  
  38. typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *rsrc);
  39. #define ZEND_RSRC_DTOR_FUNC(name)        void name(zend_rsrc_list_entry *rsrc)
  40.  
  41. typedef struct _zend_rsrc_list_dtors_entry {
  42.     /* old style destructors */
  43.     void (*list_dtor)(void *);
  44.     void (*plist_dtor)(void *);
  45.  
  46.     /* new style destructors */
  47.     rsrc_dtor_func_t list_dtor_ex;
  48.     rsrc_dtor_func_t plist_dtor_ex;
  49.  
  50.     char *type_name;
  51.  
  52.     int module_number;
  53.     int resource_id;
  54.     unsigned char type;
  55. } zend_rsrc_list_dtors_entry;
  56.  
  57.  
  58. #define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
  59. ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
  60. ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
  61.  
  62. enum list_entry_type {
  63.     LE_DB=1000
  64. };
  65.  
  66. void list_entry_destructor(void *ptr);
  67. void plist_entry_destructor(void *ptr);
  68.  
  69. void zend_clean_module_rsrc_dtors(int module_number);
  70. int zend_init_rsrc_list(ELS_D);
  71. int zend_init_rsrc_plist(ELS_D);
  72. void zend_destroy_rsrc_list(ELS_D);
  73. void zend_destroy_rsrc_plist(ELS_D);
  74. int zend_init_rsrc_list_dtors();
  75. void zend_destroy_rsrc_list_dtors();
  76.  
  77. ZEND_API int zend_list_insert(void *ptr, int type);
  78. ZEND_API int zend_plist_insert(void *ptr, int type);
  79. ZEND_API int zend_list_addref(int id);
  80. ZEND_API int zend_list_delete(int id);
  81. ZEND_API int zend_plist_delete(int id);
  82. ZEND_API int zend_list_convert_to_number(int id);
  83. ZEND_API void *zend_list_find(int id, int *type);
  84. ZEND_API void *zend_plist_find(int id, int *type);
  85.  
  86. ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
  87. ZEND_API void *zend_fetch_resource(zval **passed_id, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
  88.  
  89. ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource);
  90.  
  91. extern ZEND_API int le_index_ptr;  /* list entry type for index pointers */
  92.  
  93. #define ZEND_VERIFY_RESOURCE(rsrc)        \
  94.     if (!rsrc) {                        \
  95.         RETURN_NULL();                    \
  96.     }
  97.  
  98. #define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)    \
  99.     rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type);    \
  100.     ZEND_VERIFY_RESOURCE(rsrc);
  101.  
  102. #define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1,resource_type2)    \
  103.     rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2);    \
  104.     ZEND_VERIFY_RESOURCE(rsrc);
  105.  
  106. #define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type)  \
  107.     zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
  108.  
  109. #endif
  110.